<?php
  include "include/config.inc.php";
  if(isset($_POST['sub']))  
  {
  	$accountName  = $_POST['accountName'];
  	$otherInfo    = $_POST['otherInfo'];
  	if(isset($_POST['profitLoss']))
  	{
  	  $insAccountTb = "INSERT INTO `account` (`accountName`, `otherInfo`, `inludeInPL`)
  	                        VALUES('".$accountName."', '".$otherInfo."', 'Y')";
  	}
  	else
    {
      $insAccountTb = "INSERT INTO `account` (`accountName`, `otherInfo`, `inludeInPL`)
  	                        VALUES('".$accountName."', '".$otherInfo."', 'N')";
    }
  	
  	
  	
  	if($insAccountTbRes=mysql_query($insAccountTb) == FALSE)
  	{
  	  echo "<script>alert('Account not inserted...');</script>";
  	}
  }
  
  $account = array();
  $i = 0;
  $accountSel    = "SELECT accountId, accountName, otherInfo
                      FROM account";
  $accountSelRes = mysql_query($accountSel);
  while($accountRow = mysql_fetch_array($accountSelRes))
  {
    $account[$i]['accountId']   = $accountRow['accountId'];
    $account[$i]['accountName'] = $accountRow['accountName'];
    $account[$i]['otherInfo']   = $accountRow['otherInfo'];
    $i++;
  }
  
  $smarty->assign('account', $account);
  $smarty->display('account.tpl');
?>